#pragma once

#include <iostream>
#include <pthread.h>
#include "Mutex.hpp"

namespace My_Cond
{
    class Cond
    {
    public:
        Cond()
        {
            pthread_cond_init(&_cond, nullptr);
        }
        void Wait(My_Mutex::Mutex &mutex)
        {
            pthread_cond_wait(&_cond, mutex.MutexPtr());
        }
        void Weak()
        {
            pthread_cond_signal(&_cond);
        }
        void WeakAll()
        {
            pthread_cond_broadcast(&_cond);
        }
        ~Cond()
        {
            pthread_cond_destroy(&_cond);
        }
    private:
        pthread_cond_t _cond;
    };

} // namespace My_Cond
